import { useTranslation } from 'react-i18next';
import './LanguageSwitcher.css';

const LanguageSwitcher = () => {
  const { i18n } = useTranslation();

  const toggleLanguage = () => {
    // Switch to the other language
    const newLang = i18n.language === 'en' ? 'zh' : 'en';
    i18n.changeLanguage(newLang);
  };

  // Determine button text based on current language, as requested
  const buttonText = i18n.language === 'en' ? 'zh/en' : '中/英';

  return (
    <div className="language-switcher">
      <button onClick={toggleLanguage}>
        {buttonText}
      </button>
    </div>
  );
};

export default LanguageSwitcher;